/*-------------------------------------------------
  ajax  组件
    开发人：tss
    开发时间：2010-08-23
    修改人： 
---------------------------------------------------*/
var xmlHttp = null;

/**
 * 创建ajax 对象
 */
createAjax = function() {
	
	var tempXmlHttp = null;
	try {
		// Firefox, Opera 8.0+, Safari
		tempXmlHttp = new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			tempXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				tempXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("您的浏览器不支持AJAX！");
				return false;
			}
		}
	}
	return tempXmlHttp;
};

xmlHttp = createAjax();

xmlHttp.onreadystatechange = function() {
	
	if (xmlHttp.readyState == 4) {  //从服务器的response获得数据
		var text =  xmlHttp.responseText;
		if(text != null){
			result = eval(text);
		}
	}
};

var result;

function dwrExec(contextPath,jsName,methodName,arguments){
	
	var args = "";
	if(arguments != null && arguments.length > 0){
		for(var i = 0; i < arguments.length; i++){
			args = arguments[i].toString() + ",";
		}
	}
    if(args != "" && args.indexOf(",") != -1){
    	args = args.substring(0,args.length-1);
    }
    args = "jsName="+jsName + "&methodName="+methodName + "&args="+args;
    var url = contextPath+"/dwr/execFun?"+args;
    //xmlHttp = createAjax();
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
